home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # Rebuild .dir.tiff images for each folder.
- # Timothy Reed (c) 1995
- # treed@gun.com or next-icon-request@gun.com Sat Apr 8 14:01:15 EDT 1995
-
- # Set DEBUG=YES in your environment to see output, or uncomment the
- # following line.
- # DEBUG=YES
-
- PROG="`basename $0`"
-
- for DIR in $* ; do
- #
- # Skip $x if it isn't a directory
- if test ! -d "$DIR" ; then
- if test -n "${DEBUG}" ; then
- echo "$DIR is not a directory." >&2
- fi
- continue
- #
- # Skip $x if it's a rich text directory.
- elif test "$DIR" = "*rtfd" ; then
- if test -n "${DEBUG}" ; then
- echo "$DIR is not an appropriate directory." >&2
- fi
- continue
- fi
- (
- #
- # Go into $DIR
- cd "$DIR"
- if test $? != 0 ; then
- if test -n "${DEBUG}" ; then
- echo "Could not cd into $DIR." >&2
- fi
- continue
- fi
- #
- # For each directory in $DIR.
- for PKG in * ; do
- #
- # Skip $PKG if it isn't a directory.
- if test ! -d "$PKG" ; then
- if test -n "${DEBUG}" ; then
- echo "${DIR}/$PKG is not a directory." >&2
- fi
- continue
- #
- # Skip $PKG if .dir.tiff is already there.
- elif test -f ${PKG}/.dir.tiff -o -h ${PKG}/.dir.tiff ; then
- if test -n "${DEBUG}" ; then
- echo "${DIR}/$PKG/.dir.tiff already exists." >&2
- fi
- continue
- fi
- (
- #
- # Go into $PKG
- cd "${PKG}"
- #
- # Skip $PKG if cd $PKG failed.
- if test $? != 0 ; then
- if test -n "${DEBUG}" ; then
- echo "Could not cd into ${DIR}/$PKG." >&2
- fi
- continue
- fi
- #
- # Find the newest .tiff image.
- IMAGE="`ls -t *.tiff 2>/dev/null | head -1`"
- #
- # Skip $PKG if $IMAGE is empty
- if test -z "${IMAGE}" ; then
- echo "Could not find an image in ${DIR}/${PKG}." >&2
- continue
- fi
- echo "Linking ${DIR}/${PKG}/${IMAGE} to .dir.tiff" >&2
- ln -s "${IMAGE}" .dir.tiff
- if test $? != 0 ; then
- echo "Problem linking ${DIR}/${PKG}/${IMAGE} to .dir.tiff." >&2
- continue
- fi
- )
-
- done
- )
- done
-